< previous page page_291 next page >

Page 291
Using control arrays, you can avoid hitting the limit of 254 control names per form. Because a control array uses only one name, you can have as many elements of the array as you need. This capability allows you to place more controls on a form.
CAUTION
Don't get control-happy! Placing too many controls on a form makes your forms load slowly and can exhaust your system resources.

Creating a Control Array
You must create a control array at designtime. Although you can add elements to a control array at runtime, at least the first element of the array must be created in the design environment.
You can create a control array in three ways:
Add a control to a form and then use the design environment's Copy and Paste capabilities to duplicate the control on the form.
Add individual controls to a form and then change the Name properties of all the controls to the same value.
After adding a control to your form, set its Index property to a number between 0 and 32767.
In the following sections, you'll work through the steps of creating a control array using the first method described.
Adding Control Arrays to a Form
Here, you'll add a four-element array of text boxes and another four-element array of labels to a form. Follow these steps to create the two control arrays:
textbox.gif1. Start a new project, if necessary. Add a new TextBox control to the form, as shown in Figure 13.1.
0291-01.jpg
Figure 13.1
Although this text box will be part of a control
array, it is initially created by normal means.

 
< previous page page_291 next page >